#include <iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
const int size1 = 10 * 10 * 10 * 10 + 1;
int A[size1];
int main()
{
	int n,x;

	cin >> n;
	for (int i = 0; i < size1; i++)
	{
		
		A[i] = 0;

	}
	for (int i=0;i<n;i++)
	{
		cin >> x;
		A[x]++;
		
	}

	for (int i = 0; i < size1; i++)
	{
		if (A[i]==1)
		{
			cout << i;
			return 0;
		}
	}
	cout << -1;
    return 0;
}
